package com.example.libraryapp.notice;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.database.Cursor;

import com.example.libraryapp.db.MySqliteHelper;
import com.example.libraryapp.util.Constance;

/**
 * 公告详情服务，主要提供对公告信息的管理
 */
public class NoticeDetailService {
	/**
	 * 
	 * @return
	 */
	public static List<NoticeDetailInfo> getNoticeDetail(Context context,
			int did) {

		List<NoticeDetailInfo> noticeList = null;
		String where = " did= '" + did + "'";
		Cursor cursor = MySqliteHelper.getInstance(context).query(
				Constance.NOTICEDETAIL_TABLE_NMAE, where);
		if (cursor != null) {
			noticeList = new ArrayList<NoticeDetailInfo>();
			while (cursor.moveToNext()) {
				NoticeDetailInfo noticeInfo = new NoticeDetailInfo();
				noticeInfo.setId(cursor.getInt(cursor.getColumnIndex("id")));
				noticeInfo.setDid(cursor.getInt(cursor.getColumnIndex("did")));
				noticeInfo.setContent(cursor.getString(cursor
						.getColumnIndex("content")));
				noticeInfo.setImageId(cursor.getInt(cursor
						.getColumnIndex("imageid")));
				noticeList.add(noticeInfo);
			}
		}
		return noticeList;
	}
}
